export default {

    namespaced: true,

    state: {
        carts: [],
        cartsBuyNum:localStorage.getItem('cartsBuyNum') || 0
    },
    getters: {
        
    },
    mutations: {
        setCartsBuyNum(state) {
            state.cartsBuyNum++
            localStorage.setItem('cartsBuyNum',state.cartsBuyNum)
        },
        setCarts(state, data) {
            state.carts = data
        }
    },
    actions: {
        setCarts(context){
            let resData = [
                {id:1,title:'张三',price:1.11},
                {id:2,title:'张三',price:2.11},
                {id:3,title:'张三',price:3.11},
                {id:4,title:'张三',price:4.11},
            ]
            context.commit('setCarts',resData)
        }
    }
}
